% !TEX TS-program = pdflatex
% !TEX encoding = UTF-8 Unicode

% This is a simple template for a LaTeX document using the "article" class.
% See "book", "report", "letter" for other types of document.

\documentclass[11pt]{article} % use larger type; default would be 10pt

\usepackage[utf8]{inputenc} % set input encoding (not needed with XeLaTeX)

%%% Examples of Article customizations
% These packages are optional, depending whether you want the features they provide.
% See the LaTeX Companion or other references for full information.

%%% PAGE DIMENSIONS
\usepackage{geometry} % to change the page dimensions
\geometry{a4paper} % or letterpaper (US) or a5paper or....
% \geometry{margins=2in} % for example, change the margins to 2 inches all round
% \geometry{landscape} % set up the page for landscape
%   read geometry.pdf for detailed page layout information

\usepackage{graphicx} % support the \includegraphics command and options

% \usepackage[parfill]{parskip} % Activate to begin paragraphs with an empty line rather than an indent

%%% PACKAGES
\usepackage{booktabs} % for much better looking tables
\usepackage{array} % for better arrays (eg matrices) in maths
\usepackage{paralist} % very flexible & customisable lists (eg. enumerate/itemize, etc.)
\usepackage{verbatim} % adds environment for commenting out blocks of text & for better verbatim
\usepackage{subfig} % make it possible to include more than one captioned figure/table in a single float
% These packages are all incorporated in the memoir class to one degree or another...

%%% HEADERS & FOOTERS
\usepackage{fancyhdr} % This should be set AFTER setting up the page geometry
\pagestyle{fancy} % options: empty , plain , fancy
\renewcommand{\headrulewidth}{0pt} % customise the layout...
\lhead{}\chead{}\rhead{}
\lfoot{}\cfoot{\thepage}\rfoot{}

%%% SECTION TITLE APPEARANCE
\usepackage{sectsty}
\allsectionsfont{\sffamily\mdseries\upshape} % (See the fntguide.pdf for font help)
% (This matches ConTeXt defaults)

%%% ToC (table of contents) APPEARANCE
\usepackage[nottoc,notlof,notlot]{tocbibind} % Put the bibliography in the ToC
\usepackage[titles,subfigure]{tocloft} % Alter the style of the Table of Contents
\renewcommand{\cftsecfont}{\rmfamily\mdseries\upshape}
\renewcommand{\cftsecpagefont}{\rmfamily\mdseries\upshape} % No bold!

%%% END Article customizations

%%% The "real" document content comes below...

\title{TURFBOT - Serial Port Communications Protocol DOCUMENTATION}
\author{Junior Samaroo}
%\date{} % Activate to display a given date or no date (if empty),
         % otherwise the current date is printed 

\begin{document}
\maketitle

\section{NOTE:}
\begin{itemize}
\item{Before program can be compiled/executed "libserial" must be installed.
	  	LibSerial provides a collection of C++ classes that allow one to access serial ports on 
	  	POSIX systems like standard C++ iostream objects. More information can be obtained at
	  	http://libserial.sourceforge.net/ or see "Further readings" at bottom of this document.}
\item{After installation user must have added the "-lserial" flag if using eclipse.
	  Also user must correctly set/adjust the appropriate \#define statements in read\_serial\_port.c to indicate which port to open and where to save text files.}
\end{itemize}

\section{Problem Solved:}
\begin{itemize}
\item{A serial communications protocol was implemented that would allow you to read from the GPS unit. This code can be easily expanded to support reading/parsing from the IMU. Useful information from the GPS unit is stored in a text file for analysis.}
\subsection{nmeaData.txt}
\begin{itemize}
\item{stores the raw GGA and RMC nmea sentences. This file can be uploaded to 
				   http://www.gpsvisualizer.com/ to see the route recorded in the file in
				   google maps.
				   To further analyse the NMEA sentence data, more information can be 
				   obtained at http://www.gpsinformation.org/dale/nmea.htm\#GGA}
\end{itemize}
\subsection{gpsData.txt}
\begin{itemize}
\item{contains data in the following csv format:
 				   latitude(degrees), longitude(degrees), altitude(metres), geoid height(meters), \# of satellites, speed(metres per second)}
\end{itemize}
\end{itemize}
	
	
\section{Design notes / How problem was solved:}
\begin{itemize}
\item{Serial port communication is very complicated and thus with the use of "libserial" makes it very simplified, where the serial port being used is treated as an iostream object.}
\item{The nmea sentences read are stored as strings and parsed for the appropriate data. This data is stored in an array of strings where the data needed is simply obtained by accessing the appropriate element of the array.}
\item{Once data is obtained and stored it is written to files. Only valid data is recorded.}
\end{itemize}

\section{Limitations/Assumptions:}
\begin{itemize}
\item{By default it is assumed that port "/dev/ttyUSB0" is used and text files are stored on the desktop. This can be simply be changed in the source code as required from the \#define statements. Further running the program also appends to this text file.}
\item{Also it is assumed that "libserial" is installed and the machine the program is running on is POSIX compliant.}
\item{The user must also know how to explicitly stop programs and add the "-lserial" flag if eclipse is used.}
\end{itemize}

\section{Testing:}
\begin{itemize}
\item{Experiments were set up whereby data was collected while walking in an open field. This data was then checked using gpsvisualizer.com using the both text files. Both google maps results matched, indicating correct recorded data.}
\end{itemize}

\section{Improvements:}
\begin{itemize}
\item{More accuracy and precision experiments need to be carried out.}
\item{More data fields to gpsData.txt can be added if needed.}
\end{itemize}

\section{Further Readings:}
\subsection{Correctly installing libserial if errors were encountered:}
\begin{itemize}
\item{Please  read http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1265091638 and make sure that these headers are included in the source files of the unzipped libserial tarball:}
\end{itemize}
\begin{verbatim}

                src/PosixSignalDispatcher.cpp
                #include <string.h>

                src/SerialPort.cpp
                #include <string.h>
                #include <stdlib.h>

                src/SerialStreamBuf.cc
                #include <string.h>

                examples/read_port.cpp
                #include <stdlib.h>

                examples/write_port.cpp
                #include <stdlib.h>
				
\end{verbatim}
\subsection{Adding the -lserial flag in eclpise:}
\begin{itemize}
\item{go to "Project" then "Properties" then "C/C++ Build" and finally "Settings". Under Tool Settings tab click "GCC C++ Linker" and click "Libraries". Then add a new library and in the window that pops up type "serial" without quotes, save and compile. Libserial must be installed for this to work.}
\end{itemize}



\end{document}
